﻿using UnityEngine;

namespace TC
{
    public class MoveTo : FunctionNode, IUpdate
    {
        public bool wait;
        public ValueInput<GameObject> target;
        public ValueInput<Vector3> dest;

        public float speed;

        public override void OnCreate()
        {
            base.OnCreate();

            target = this.AddValueInPort<GameObject>("target");
            dest = this.AddValueInPort<Vector3>("dest");
        }

        public void OnUpdate(float delta)
        {
            Transform transform = target.Value.transform;
            if(transform.position == dest.Value)
            {
                transform.position = Vector3.MoveTowards(transform.position, dest.Value, speed * delta);
            }
        }
    }
}
